
//
// Copyright (c) 2008, the /*jupiter jazz*/ group
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of the /*jupiter jazz*/ group nor the
//       names of its contributors may be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY the /*jupiter jazz*/ group ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL the /*jupiter jazz*/ group BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#ifndef CLASSLIB_CANVASPROPERTIES_H
#define CLASSLIB_CANVASPROPERTIES_H

// Standard headers.
#include <cassert>
#include <cstddef>

namespace foundation
{

//
// Supported pixel formats.
//

enum PixelFormat
{
    PixelFormatUInt8 = 0,
    PixelFormatUInt16,
    PixelFormatUInt32,
    PixelFormatHalf,
    PixelFormatFloat,
    PixelFormatDouble
};

// Return the size in bytes of a given pixel format.
inline size_t pixel_size(PixelFormat format)
{
    switch (format)
    {
      case PixelFormatUInt8:    return 1;
      case PixelFormatUInt16:   return 2;
      case PixelFormatUInt32:   return 4;
      case PixelFormatHalf:     return 2;
      case PixelFormatFloat:    return 4;
      case PixelFormatDouble:   return 8;
      default:
        assert(false);
        return 0;
    }
}


//
// Canvas properties.
//

class CanvasProperties
{
  public:
    size_t              m_canvas_width;             // canvas width, in pixels
    size_t              m_canvas_height;            // canvas height, in pixels
    double              m_inv_canvas_width;         // canvas width reciprocal
    double              m_inv_canvas_height;        // canvas height reciprocal
    size_t              m_pixel_count;              // number of pixels in the canvas

    size_t              m_tile_width;               // tile width, in pixels
    size_t              m_tile_height;              // tile height, in pixels
    double              m_inv_tile_width;           // tile width reciprocal
    double              m_inv_tile_height;          // tile height reciprocal
    size_t              m_tile_count_x;             // number of tiles horizontally
    size_t              m_tile_count_y;             // number of tiles vertically
    size_t              m_tile_count;               // number of tiles in the canvas

    PixelFormat         m_pixel_format;             // pixel format
    size_t              m_channel_count;            // number of channels per pixel
    size_t              m_pixel_size;               // size in bytes of one pixel
};

}       // namespace foundation

#endif  // !CLASSLIB_CANVASPROPERTIES_H
